<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
          *****
          ****
          ***
          **
          *
          思路：双重for 循环，外层控制行，内层控制列
          i       num 的最大值
          0           5
          1           4
          2           3
          3           2
          4           1
          
          i + num = 5
          num = 5 - i;
      */
        var num = prompt('请输入行数');
        var num1 = prompt('请输入列数');
         for (let i = 0; i < num; i++) {

            let star = '';
            for (let k = 0; k < num1 - i; k++) {
                star = star + '*';
            }
            console.log(star);
        }


        for (let i = 0; i < num; i++) {
            let star = '';
            for (let k = 0; k < i + 1; k++) {
                star = star + '*';
            }
            console.log(star);
        }
 
 

        for (let i = 0; i < num; i++) {
            let star = '';
            for (let k = 0; k < num1 - i; k++) {
                star = star + ' ';
            }
            for (let k = 0; k < i + 1; k++) {
                star = star + '*';
            }
            console.log(star);
        }

    </script>
</body>

</html>